package com.hh.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.hh.dao.UserDao;
import com.hh.entity.PlanItem;
import com.hh.entity.User;

@Repository
public class UserDaoImpl implements UserDao{
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@Override
	public User findUser(String uname, String upass) {
		String sql="select * from s_users where uname=? and upass=?";
		List list=jdbcTemplate.query(sql,new BeanPropertyRowMapper(User.class),uname,upass);
		if (list.isEmpty()) {
			return null;
		}
		return (User)list.get(0);
	}

	@Override
	public List findDate(int uid) {
		String sql="select * from s_planitem where uid=?";
		List list=jdbcTemplate.query(sql,new BeanPropertyRowMapper(PlanItem.class),uid);
		return list;
	}
	
}
